home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-05-23 | 9.5 KB | 281 lines | [TEXT/MACA] |
- /* ----------------- push -----------------
- *
- * A little guy will push away your screen.
- * What a brutality!!
- * You will have to restart the system after you're through
- * watching him!
- * Written in Aztec C.
- *
- * Author: Fons Rademakers
- * Nikhef-h (Nat. Inst. for High Energy Physics)
- * the Netherlands
- * Version: 21-nov-1985
- * Revision:
- *
- */
-
- #asm
- main
- dc.w $6400 ;ctl-enable, need time and locked in mem.
- dc.w 0 ;update as often as possible
- dc.w $0001 ;don't react on any specific event
- dc.w 0 ;no menu
-
- dc.w open_-main ;open routine
- dc.w nop_-main ;prime routine
- dc.w control_-main ;control routine
- dc.w nop_-main ;status routine
- dc.w close_-main ;close routine
-
- title_
- dc.b 4
- dc.b "Push"
- ds 0 ;for alignment
-
- public _Uend_,_Dorg_,_Cend_
-
- save_
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ;set up globals
- move.l a0,Pbp_ ;save pb pointer
- move.l a1,Dp_ ;save DCE pointer
- rts
-
- restore_
- move.l Pbp_,a0
- rts
- #endasm
-
- #define _DRIVER
- #define SMALL_MEM
- #include <quickdraw.h>
- #include <memory.h>
- #undef SMALL_MEM
- #include <event.h>
- #include <pb.h>
- #include <desk.h>
-
- #define notSrcCopy 4 /* Not in QD with SMALL_MEM flag set */
- #define NULL (0L)
-
- #define BASE1 512 /* Mac screen size in x direction */
- #define BASE2 342 /* Mac screen size in y direction */
-
- #define SP (*(struct storage **)Dp->dCtlStorage)
-
- DCEPtr Dp;
- ParmBlkPtr Pbp;
-
- Rect wind_rect = {0, 0, 0, 0};
-
- struct storage {
- GrafPtr pushport; /* the push grafport */
- BitMap manmap[3]; /* the 3 amn bitmaps */
- Pattern black;
- short portspace[54]; /* space for the flowport */
- char manspace[3][348]; /* space for the 3 man bitmaps */
- short x;
- };
-
- open()
- {
- register WindowPtr wp;
- register struct DCE *dp;
- register struct storage *sp;
- extern char title[];
- struct windowpeek {
- GrafPort port;
- int windowKind;
- };
- short i;
-
- save();
- dp = Dp;
- if (dp->dCtlWindow == NULL) {
- HLock(dp->dCtlStorage = NewHandle((long) sizeof(struct storage)));
- sp = SP;
- /* create an invisible window */
- dp->dCtlWindow =
- wp = NewWindow(NULL, &wind_rect, title, FALSE, plainDBox, -1L, FALSE,
- NULL);
- ((struct windowpeek *)wp)->windowKind = dp->dCtlRefNum;
- /* allocate space for new pushport */
- &sp->pushport->device = sp->portspace;
- OpenPort(sp->pushport);
- /* set the 3 man bitmaps */
- for (i = 0; i < 3 ; i++) {
- sp->manmap[i].bounds.top = 0;
- sp->manmap[i].bounds.left = 0;
- sp->manmap[i].bounds.bottom = 58;
- sp->manmap[i].bounds.right = 48;
- sp->manmap[i].rowBytes = 6;
- sp->manmap[i].baseAddr = &sp->manspace[i][0];
- }
- /* first man map */
- StuffHex(sp->manmap[0].baseAddr, "\P00000000001000000000001800000000001C");
- StuffHex(sp->manmap[0].baseAddr+18, "\P000000000020000000000040000000000080");
- StuffHex(sp->manmap[0].baseAddr+36, "\P000000000100000000000200000000000400");
- StuffHex(sp->manmap[0].baseAddr+54, "\P000000000800000000001000000000002000");
- StuffHex(sp->manmap[0].baseAddr+72, "\P003F00004000007F80008000007C80010000");
- StuffHex(sp->manmap[0].baseAddr+90, "\P007900220000007080740000002100E80000");
- StuffHex(sp->manmap[0].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
- StuffHex(sp->manmap[0].baseAddr+126,"\P004784C800000041CB10000000403C200000");
- StuffHex(sp->manmap[0].baseAddr+144,"\P004000C0000000438300000000407C000000");
- StuffHex(sp->manmap[0].baseAddr+162,"\P004080000000004080000000004080000000");
- StuffHex(sp->manmap[0].baseAddr+180,"\P004080000000002080000000003F80000000");
- StuffHex(sp->manmap[0].baseAddr+198,"\P002080000000002080000000001080000000");
- StuffHex(sp->manmap[0].baseAddr+216,"\P001100000000001100000000001100000000");
- StuffHex(sp->manmap[0].baseAddr+234,"\P001100000000001100000000001100000000");
- StuffHex(sp->manmap[0].baseAddr+252,"\P001100000000001200000000001200000000");
- StuffHex(sp->manmap[0].baseAddr+270,"\P001200000000001200000000001200000000");
- StuffHex(sp->manmap[0].baseAddr+288,"\P001200000000003F00000000003F00000000");
- StuffHex(sp->manmap[0].baseAddr+306,"\P003F00000000001200000000001200000000");
- StuffHex(sp->manmap[0].baseAddr+324,"\P0012000000000013C0000000001420000000");
- StuffHex(sp->manmap[0].baseAddr+342,"\P001BE0000000");
-
- /* second man map */
- StuffHex(sp->manmap[1].baseAddr, "\P00000000001000000000001800000000001C");
- StuffHex(sp->manmap[1].baseAddr+18, "\P000000000020000000000040000000000080");
- StuffHex(sp->manmap[1].baseAddr+36, "\P000000000100000000000200000000000400");
- StuffHex(sp->manmap[1].baseAddr+54, "\P000000000800000000001000000000002000");
- StuffHex(sp->manmap[1].baseAddr+72, "\P003F00004000007F80008000007C80010000");
- StuffHex(sp->manmap[1].baseAddr+90, "\P007900220000007080740000002100E80000");
- StuffHex(sp->manmap[1].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
- StuffHex(sp->manmap[1].baseAddr+126,"\P004784C800000041CB10000000403C200000");
- StuffHex(sp->manmap[1].baseAddr+144,"\P004000C0000000438300000000407C000000");
- StuffHex(sp->manmap[1].baseAddr+162,"\P004080000000004080000000004080000000");
- StuffHex(sp->manmap[1].baseAddr+180,"\P004080000000002080000000003F80000000");
- StuffHex(sp->manmap[1].baseAddr+198,"\P002080000000002080000000001080000000");
- StuffHex(sp->manmap[1].baseAddr+216,"\P001080000000001080000000001240000000");
- StuffHex(sp->manmap[1].baseAddr+234,"\P001240000000001220000000001320000000");
- StuffHex(sp->manmap[1].baseAddr+252,"\P002310000000002690000000004488000000");
- StuffHex(sp->manmap[1].baseAddr+270,"\P00484800000000884C000000009024000000");
- StuffHex(sp->manmap[1].baseAddr+288,"\P01102400000003F07E00000003F07E000000");
- StuffHex(sp->manmap[1].baseAddr+306,"\P03F07E000000012024000000012024000000");
- StuffHex(sp->manmap[1].baseAddr+324,"\P012024000000013C27800000014228400000");
- StuffHex(sp->manmap[1].baseAddr+342,"\P01BE37C00000");
-
- /* third man map */
- StuffHex(sp->manmap[2].baseAddr, "\P00000000001000000000001800000000001C");
- StuffHex(sp->manmap[2].baseAddr+18, "\P000000000020000000000040000000000080");
- StuffHex(sp->manmap[2].baseAddr+36, "\P000000000100000000000200000000000400");
- StuffHex(sp->manmap[2].baseAddr+54, "\P000000000800000000001000000000002000");
- StuffHex(sp->manmap[2].baseAddr+72, "\P003F00004000007F80008000007C80010000");
- StuffHex(sp->manmap[2].baseAddr+90, "\P007900220000007080740000002100E80000");
- StuffHex(sp->manmap[2].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
- StuffHex(sp->manmap[2].baseAddr+126,"\P004784C800000041CB10000000403C200000");
- StuffHex(sp->manmap[2].baseAddr+144,"\P004000C0000000438300000000407C000000");
- StuffHex(sp->manmap[2].baseAddr+162,"\P004080000000004080000000004080000000");
- StuffHex(sp->manmap[2].baseAddr+180,"\P004080000000002080000000003F80000000");
- StuffHex(sp->manmap[2].baseAddr+198,"\P002080000000002080000000001080000000");
- StuffHex(sp->manmap[2].baseAddr+216,"\P001080000000001080000000001240000000");
- StuffHex(sp->manmap[2].baseAddr+234,"\P001240000000001220000000001320000000");
- StuffHex(sp->manmap[2].baseAddr+252,"\P002310000000004490000000008888000000");
- StuffHex(sp->manmap[2].baseAddr+270,"\P01104800000006204C0000000F4024000000");
- StuffHex(sp->manmap[2].baseAddr+288,"\P0F802400000017807E00000023007E000000");
- StuffHex(sp->manmap[2].baseAddr+306,"\P44007E000000880024000000D00024000000");
- StuffHex(sp->manmap[2].baseAddr+324,"\P480024000000240027800000120028400000");
- StuffHex(sp->manmap[2].baseAddr+342,"\P0E0037C00000");
-
- /* set start x value */
- sp->x = 0;
- /* black pattern */
- StuffHex(sp->black, "\PFFFFFFFFFFFFFFFF");
- /* set the background pattern to black */
- BackPat(sp->black);
-
- HUnlock(dp->dCtlStorage);
- }
- restore();
- return(0);
- }
-
-
- close()
- {
- register struct DCE *dp;
-
- save();
- dp = Dp;
- /* get rid of the allocated space for the window */
- DisposeWindow(dp->dCtlWindow);
- dp->dCtlWindow = NULL;
- DisposHandle(dp->dCtlStorage);
- restore();
- return(0);
- }
-
-
- nop()
- {
- return(0);
- }
-
-
-
-
- control()
- {
- register struct DCE *dp;
- register struct storage *sp;
- short i, j;
- short xdest, ydest;
- short xvel, slowdown;
- Rect destrect;
- RgnHandle dummyrgn;
-
- save();
- dp = Dp;
- HLock(dp->dCtlStorage);
- sp = SP;
- switch (Pbp->u.cp.csCode) {
- case accRun: /* time to push the screen */
- SetPort(sp->pushport);
-
- xvel = 2; /* speed with which the screen is being pushed by the man
- */
-
- /* to prevent man from walking too fast at end of screen, slow him down
- */
- if (sp->x < 128) /* 1/4*BASE1 */
- slowdown = 0;
- else if (sp->x < 256) /* 1/2*BASE1 */
- slowdown = 1000;
- else if (sp->x < 384) /* 3/4*BASE1 */
- slowdown = 5000;
- else
- slowdown = 10000;
-
- for (i = 0; i < 3; i++) {
- for (j = 0; j <= slowdown; j++)
- ;
- if (sp->x <= BASE1 + 48) {
- dummyrgn = NewRgn();
- SetRect(&destrect, sp->x, 0, BASE1, BASE2);
- xdest = xvel;
- ydest = 0;
- ScrollRect(&destrect, xdest, ydest, dummyrgn);
- sp->x += xvel;
-
- /* kind of dirty fix: erase heel of third man map.
- * I should have defined the man maps 1 word bigger on the left side
- * to prevent this EraseRect call */
- if (!i) {
- SetRect(&destrect, sp->x - 56, BASE2 - 13, sp->x - 48, BASE2);
- EraseRect(&destrect);
- }
-
- SetRect(&destrect, sp->x - 48, BASE2 - 58, sp->x, BASE2);
- CopyBits(&sp->manmap[i], &sp->pushport->portBits,
- &sp->manmap[i].bounds, &destrect,
- notSrcCopy, NULL);
- DisposeRgn(dummyrgn);
- } else
- sp->x = 0;
- }
- break; /* end case */
- }
- HUnlock(dp->dCtlStorage);
- restore();
- return(0);
- }
-